package day09;

public class student {
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if(name.length()>=3&&name.length()<=10) {
            this.name = name;
        }else {
            throw new StudentInitnameException(name+"名字数值非法，范围为3-10位");
        }
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age>=18&&age<=40) {
            this.age = age;
        }else {
            throw new StudentInitageException(age+"年龄数值非法，范围为18-40");
        }
    }

    public student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public student() {
    }
}
